/*****************************************************************
**                                                             	**
**  Copyright (C) 2005 Amlogic,Inc.                            	**
**  All rights reserved                                        	**
**        Filename : Win15Pic.c /Project:AVOS		       **
**        Revision : 1.0                                       	**
**                                                             	**
*****************************************************************/
#include "../menu.h"
#include "user.h"
#include "Win15PicEvent.h"
#include "logo_dat.h" 
#include "..\aw_PIC_app.h"
#include "aw_pic_util.h"
#include"..\aw_GPLAYER_app.h"
#include"LogoEvent.h"
#include"ctrlconvert.h"
#include "NetmenuSetupEvent.h"

int MultiMenuToSingle=0;
int uop_resume_15pic=0;

extern INT8U ShowSixPicFlag ;
extern INT8U filelist_show_flag ;
extern INT8U  FileMenuToSingle  ;
extern INT16U JpegPlayStatus ;
extern int restore_key ;
extern int pic_slide_show_mode;
extern int uop_home_flag;
extern int SHOW_WINDOW_NUM ;
extern int SIXPIC_ROW_TOTAL;
extern int SIXPIC_LINE_TOTAL;

extern void SetPicRunStatus(INT8U flag);

extern void AWPICKeyDo(INT32S key);

extern void PicParaTrans(void);

extern INT32S display_multi_pic(void);

void UpdateSixPicFocus(PHWND hwnd,int pic_focus)
{     
  PHWND wnd=NULL; 
  if(hwnd){   
	int focus_flag=(pic_focus%SHOW_WINDOW_NUM);
	for(INT8U i=0;i<SHOW_WINDOW_NUM;i++)
	{
        if(i == focus_flag)
            hwnd->draw_info[i+2].draw_data = (INT32U)ICON_PIC_FOCUS;
        else
            hwnd->draw_info[i+2].draw_data = (INT32U)ICON_PIC_LOSE;
            hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, i+2);
    }
        	hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0);
        }
}

INT32S Win15PicOnShow(PHWND hwnd, INT32S lpParam)
{
    unsigned char osdsettpval(unsigned char,unsigned char level);//from 0 -- 15
    osdsettpval(0,0xf);	
    ShowSixPicFlag=1;
    filelist_show_flag  =0 ;
    display_multi_pic();    
    return 0 ;
}

INT32S Win15PicBarOnShow(PHWND hwnd, INT32S lpParam)
{
		if(hwnd){
	     for(INT8U i=2;i<SHOW_WINDOW_NUM;i++)
	     {
	       hwnd->draw_info[i].draw_data = (INT32U)ICON_PIC_LOSE;
	     }
	     JpegPlayStatus=0;
		 FileMenuToSingle=0;
		 hwnd->draw_info[SHOW_WINDOW_NUM+5].draw_data =0;
		 hwnd->draw_info[SHOW_WINDOW_NUM+3].draw_data = (INT32U) 0;
		 hwnd->draw_info[SHOW_WINDOW_NUM+7].draw_data = (INT32U) 0;
		}	

    return 0 ;
}

INT32S Win15PicBarOnKeyPress(PHWND hwnd, INT32S lpParam)
{
 	  INT32U *key_value = (INT32U *)lpParam ;
      INT32S key = UOP_NOP ;
      if(hwnd){
	switch(*key_value)
	{
		case UOP_STOP:
			*key_value= UOP_NOP;
			break;      
		case UOP_LEFT:
		case UOP_RIGHT:		 
		case UOP_UP:
		case UOP_DOWN:
			MutiPicFocusOperation(SIXPIC_LINE_TOTAL,SIXPIC_ROW_TOTAL,key_value);
			key = (INT32S) *key_value;
			for(INT8U j=0;j<SHOW_WINDOW_NUM;j++)
			{
				hwnd->draw_info[j+2].draw_data = (INT32U)ICON_PIC_LOSE;
				AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, j+2) ;
			}
			AWPostMessage(hwnd, WM_PAINT_FINISH, 0) ;
			AWPICKeyDo(key) ;
			break;
		case UOP_RESUME:
		  	if(Music_Pic_mix_flag){
				AWGPLAYERQuitProcess();
		  	}
		  	uop_resume_15pic=1;
			break ;
		case UOP_ENTER:
			#ifdef ENABLE_NETWORK
			AWSetFileList(gpFocusWin,NULL,NULL);  
			#endif
			#ifdef WISTAR_VERSION
			SetPicRunStatus(0);
			MultiMenuToSingle= 2;  
			#else
			#ifdef KOREAR_REMOTE
			SetPicRunStatus(0);
			JpegPlayStatus=0;
			MultiMenuToSingle=2;
			#else
			SetPicRunStatus(1);
            disable_video_layer();
			JpegPlayStatus=0;
			MultiMenuToSingle=1;
			#endif
			#endif
	       		goto begin_play_flag;
		case UOP_END_PAUSE:		
			 #ifdef ENABLE_NETWORK
			AWSetFileList(gpFocusWin,NULL,NULL);  
			#endif
			SetPicRunStatus(0);
			MultiMenuToSingle= 2;  
				goto begin_play_flag;
		case UOP_NEXT_CHAP:
		case UOP_PREVIOUS_CHAP:
		case UOP_FAST_FORWARD:
		case UOP_FAST_BACKWARD:
    			MutiPicFocusOperation(SIXPIC_LINE_TOTAL,SIXPIC_ROW_TOTAL,key_value);
        		key = (INT32S) *key_value;
		      	AWPICKeyDo(key) ;
		      	break;
      	 begin_play_flag:		     
			AWPICKeyDo(*key_value) ;
			set_current_logo_type(0);
			hwnd->draw_info[SHOW_WINDOW_NUM+8].draw_data = (INT32U)0 ;
			ShowSixPicFlag=0;
			*key_value=UOP_NOP;
			break;
		case UOP_3:	
		case UOP_HOME:
			key=UOP_STOP;
			AWPICKeyDo(key) ;
			uop_home_flag=1;
			break;			
		default:
			break;
	}
	ClearPanelAction(key_value) ;
    return 0 ;
}
}

